# Contributor: mio <miyopan@e.email>
# Maintainer: Will Sinatra <wpsinatra@gmail.com>
pkgname=nomacs
pkgver=3.17.2285
pkgrel=0
_pluginsver=3.16
pkgdesc="Cross platform image viewer"
url="https://nomacs.org/"
license="GPL-3.0-or-later"
# ppc64le: opencv alpine/aports#15494
# riscv64: blocked by opencv
arch="all !s390x !ppc64le !riscv64"
makedepends="
	cmake
	exiv2-dev
	libraw-dev
	libjxl-dev
	libwebp-dev
	libzip-dev
	opencv-dev
	qt5-qtbase-dev
	qt5-qtscript-dev
	qt5-qtsvg-dev
	qt5-qttools-dev
	quazip-dev
	samurai
	tiff-dev
	"
subpackages="$pkgname-doc $pkgname-lang"
source="nomacs-$pkgver.tar.gz::https://github.com/nomacs/nomacs/archive/$pkgver.tar.gz
	nomacs-plugins-$_pluginsver.tar.gz::https://github.com/nomacs/nomacs-plugins/archive/$_pluginsver.tar.gz
	version.patch
	"
options="!check" # No tests

prepare() {
	default_prepare

	rm -r 3rd-party

	rmdir ImageLounge/plugins
	ln -sfv "$srcdir"/nomacs-plugins-$_pluginsver ImageLounge/plugins
}

build() {
	cmake -B build -G Ninja -S ImageLounge \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DENABLE_INCREMENTER=OFF \
		-DENABLE_JXL=ON \
		-DENABLE_TRANSLATIONS=TRUE \
		-DUSE_SYSTEM_QUAZIP=ON
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

lang() {
	pkgdesc="translations for $pkgname"
	install_if="$pkgname=$pkgver-r$pkgrel lang"

	mkdir -p "$subpkgdir/usr/share/nomacs/Image Lounge/"
	mv "$pkgdir/usr/share/nomacs/Image Lounge/translations/" \
		"$subpkgdir/usr/share/nomacs/Image Lounge/"
}

sha512sums="
7c9b04234cb936ade279d0e84fb0e3b677f09c108adf2261d05cbb91d2b5a031c71c1a12cd2c0c2ba86396f267cb9fb1e67e3ddd197160ee343b164d5fd42fcc  nomacs-3.17.2285.tar.gz
cd72f6ddbe3e07d7ed97f08405bac7574f4f3285c81e835f5630e011c8a9b105f23d892fed8084cb35ce521aca5524db071d0edb8bb04850dd2209d9ed019747  nomacs-plugins-3.16.tar.gz
bc46c024f874857199ff33246011a7ed49e2b61813dab30a92995d9571b209c7b188e6cc5100f0bc0dec0e86d6cce3135731a768642bc4cf6f32d851ac7d0afe  version.patch
"
